﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Runtime.InteropServices;
using System.Linq.Expressions;
using System.Reflection;
using Project.Common;

namespace Project.Web.Base.Utility
{
	public class WebTools
	{
		/// <summary>
		/// Main页面刷新脚本
		/// </summary>
		public static string ScriptCloseDialog
		{
			get
			{
				return "<script>window.top.closeDialog('refresh');</script>";
			}
		}

		/// <summary>
		/// PageRightFrame页面刷新脚本
		/// </summary>
		public static string ScriptClosePageRightFrameDialog
		{
			get
			{
				return "<script>window.top.closePageRightFrameDialog('refresh');</script>";
			}
		}

		/// <summary>
		/// PageRightFrame页面刷新脚本
		/// </summary>
		public static string ScriptClosePageDialogTwo
		{
			get
			{
				return "<script>window.top.closePageDialogTwo('refresh');</script>";
			}
		}

		public static string ScriptCloseAllDialog
		{
			get
			{
				return "<script>window.top.closePageDialogTwo();window.top.closeDialog('refresh');</script>";
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="isRefresh">是否需要刷新，如果需要刷新window.top,赋值'refresh'</param>
		/// <param name="dialogID">需要关闭的dialogID</param>
		/// <param name="callback">回调函数</param>
		/// <returns></returns>
		public static string GetScriptCloseDialog(string isRefresh, string message, string dialogID, string callback)
		{
			return string.Format("<script>window.top.closeDialog('{0}','{1}','{2}','{3}');</script>", isRefresh, message, dialogID, callback);
		}

		public static string GetScript(string script)
		{
			return string.Format("<script>{0}</script>",script);
		}

		/// <summary>
		/// 判断执行类型
		/// </summary>
		/// <param name="extension"></param>
		/// <returns></returns>
		public static bool IsNotExcuteAspx(string extension)
		{
			return
				extension.Equals(".css", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".js", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".gif", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".png", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".jpeg", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".ico", StringComparison.OrdinalIgnoreCase)
				|| extension.Equals(".swf", StringComparison.OrdinalIgnoreCase)
				;
		}

	}
}